﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Group3.Framework.Extensions
{
    public static class ExtensionComparrison
    {
        public static bool between<T>(this T item, T lowerbound, T upperbound) where T : System.IComparable<T>
        {
            return lowerbound.CompareTo(item) <= 0 && item.CompareTo(upperbound) <= 0;
        }

        public static bool betweenExclude<T>(this T item, T lowerbound, T upperbound) where T : System.IComparable<T>
        {
            return lowerbound.CompareTo(item) < 0 && item.CompareTo(upperbound) < 0;
        }

        public static bool betweenExcludeUpperBound<T>(this T item, T lowerbound, T upperbound) where T : System.IComparable<T>
        {
            return lowerbound.CompareTo(item) <= 0 && item.CompareTo(upperbound) < 0;
        }

        public static bool betweenExcludeLowerBound<T>(this T item, T lowerbound, T upperbound) where T : System.IComparable<T>
        {
            return lowerbound.CompareTo(item) < 0 && item.CompareTo(upperbound) <= 0;
        }

        public static bool In<T>(this T item, T[] values)
        {
            if (values == null)
                return false;
            foreach (var itm in values)
            {
                if (itm.Equals(item))
                    return true;
            }
            return false;
        }

    }
}
